package cn.tedu.fruitshop.security;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

/**
 * @author www
 * @create 2022-11-16 16:04
 */
@Setter
@Getter
@ToString(callSuper = true) //调用父类的方法生成父类的属性打印
@EqualsAndHashCode
public class UserDetails extends User {

    /**
     * 管理员的id
     */
    private Long id;

    /**
     * 管理员详情的构造方法
     * @param id 管理员id
     * @param username 管理员用户名
     * @param password 管理员密码
     * @param enabled 是否启用
     * @param authorities
     */
    public UserDetails(Long id,
                       String username,
                       String password,
                       boolean enabled,
                       Collection<? extends GrantedAuthority> authorities) {
        super(username, password, enabled,
                true, true, true,
                authorities);
        this.id = id;
    }
}

